﻿using System.ComponentModel.Composition;
using System.Windows.Media;
using Microsoft.VisualStudio.Text.Classification;
using Microsoft.VisualStudio.Utilities;

namespace YamlEditor
{
    static internal class YamlDefinitions
    {
        [Export]
        [Name("yaml")]
        [BaseDefinition("text")]
        internal static ContentTypeDefinition YamlContentTypeDefinition = null;

        [Export]
        [FileExtension(".yaml")]
        [ContentType("yaml")]
        internal static FileExtensionToContentTypeDefinition YamlFileExtensionDefinition = null;

        [Export]
        [FileExtension(".patch")]
        [ContentType("yaml")]
        internal static FileExtensionToContentTypeDefinition patchFileExtensionDefinition = null;
        
        // Classification types

        [Export]
        [Name("yaml")]
        internal static ClassificationTypeDefinition YamlClassificationDefinition = null;

        [Export]
        [Name("yaml.directive")]
        [BaseDefinition("yaml")]
        internal static ClassificationTypeDefinition YamlDirectiveDefinition = null;

        [Export]
        [Name("yaml.comment")]
        [BaseDefinition("yaml")]
        internal static ClassificationTypeDefinition YamlRemovedDefinition = null;

        [Export]
        [Name("yaml.changed")]
        [BaseDefinition("yaml")]
        internal static ClassificationTypeDefinition YamlChangedDefinition = null;

        [Export]
        [Name("yaml.infoline")]
        [BaseDefinition("yaml")]
        internal static ClassificationTypeDefinition YamlInfolineDefinition = null;

        [Export]
        [Name("yaml.patchline")]
        [BaseDefinition("yaml")]
        internal static ClassificationTypeDefinition YamlPatchLineDefinition = null;

        [Export]
        [Name("yaml.header")]
        [BaseDefinition("yaml")]
        internal static ClassificationTypeDefinition YamlHeaderDefinition = null;

        // Classification format definitions

        [Export(typeof(EditorFormatDefinition))]
        [ClassificationType(ClassificationTypeNames = "yaml.directive")]
        [Name("yaml.directive")]
        internal sealed class YamlDirectiveFormat : ClassificationFormatDefinition
        {
            public YamlDirectiveFormat()
            {
                this.ForegroundColor = Colors.Orange;
            }
        }

        [Export(typeof(EditorFormatDefinition))]
        [ClassificationType(ClassificationTypeNames = "yaml.comment")]
        [Name("yaml.comment")]
        internal sealed class YamlCommentFormat : ClassificationFormatDefinition
        {
            public YamlCommentFormat()
            {
                this.ForegroundColor = Colors.Green;
            }
        }
    }
}
